package cn.itcast.service.company.impl;

import cn.itcast.dao.company.CompanyDao;
import cn.itcast.domain.company.Company;
import cn.itcast.service.company.CompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

@Service
public class CompanyServiceImpl implements CompanyService {

	@Autowired
	private CompanyDao companyDao;

	@Override
	public List<Company> findAll() {
		return companyDao.findAll();
	}

	/**
	 * 保存
	 */
	public void save(Company company) {
		//1.设置唯一id
		company.setId(UUID.randomUUID().toString());
		//2.调用dao保存
		companyDao.save(company);
	}

	//根据id查询
	public Company findById(String id) {
		//调用dao查询
		return companyDao.findById(id);
	}

	//更新
	public void update(Company company) {
		companyDao.update(company);
	}

	//根据id删除
	public void delete(String id) {
		companyDao.delete(id);
	}
}
